<?php $this->placeholder('container-class')->set('post_ad detail job')?>
<?php $this->JQuery()->javascriptCaptureStart()?>
jQuery(function() {
    $j('#add_more_btn').click(function() {
        if ($j('#add_more_checkbox').attr('value') == 1) {
            $j('#add_more_checkbox').attr('value',0);
        }
        else {
            $j('#add_more_checkbox').attr('value',1);
        }
        $j('#add_more').toggle();
        return false;
    });

    if ($j('#add_more_checkbox').attr('value') == 0) {
        $j('#add_more').show();
    }
    else {
        $j('#add_more').hide();
    }

    // Control for Title
    $j('input#tl_en').keydown(function(event) {
        var charLength = 100 - $j(this).val().length;
        if (charLength <0) {
            if ( event.keyCode == 8 || event.keyCode == 46 ) {

            } else {
                return false;
            }
        }
        else {
            $('span.counter_title').html('剩余<em>'+charLength + '</em>字');
        }
    });

    // Control for company
    $j('input#cn_en').keydown(function(event) {
        var charLength = 100 - $j(this).val().length;
        if (charLength < 0) {
            if ( event.keyCode == 8 || event.keyCode == 46 ) {

            } else {
                return false;
            }
        }
        else {
            $('span.counter_company').html('剩余<em>'+charLength + '</em>字');
        }
    });

    // Control for description
    $('textarea#cs_en').keydown(function(event) {
        var charLength = 3000 - $(this).val().length;
        if (charLength <0) {
            if ( event.keyCode == 8 || event.keyCode == 46 ) {

            } else {
                return false;
            }
        }
        else {
            $('span.counter_description').html('还可以输入<em>'+charLength + '</em>字；为避免收到垃圾邮件，请勿输入邮箱地址');
        }
    });

    //active checkboxes
    $j('#residentstatus-5').click(function() {
        if ($(this).attr('checked')) {
            $(this).parent().parent().find('input').attr('checked', true);
        } else {
            $(this).parent().parent().find('input').attr('checked', false);
        }
    });

    $j('.residentstatus input').click(function() {
        if ($(this).attr('id') != 'residentstatus-5') {
            $j('#residentstatus-').attr('checked', false);
        }
    });

    $j('#preview_link').click(function() {
        var action = $j('#listing_form').attr('action');
        $j('#listing_form').attr('action', '<?php echo $this->preview_link?>');
        $j('#listing_form').attr('target','_blank');
        $j('#listing_form').submit();
        $j('#listing_form').attr('action', action);
        $j('#listing_form').attr('target','_self');
        return false;
    });
    
     
});
<?php $this->JQuery()->javascriptCaptureEnd()?>

<?php $errors = $this->form->getErrors(); //print_r($errors);?>
<form action="<?php echo $this->escape($this->form->getAction()) ?>" method="<?php echo $this->escape($this->form->getMethod())?>" id="listing_form"  enctype="multipart/form-data">
	<fieldset class="info">
		<legend>描述</legend>
		<div class="required"><span class="required">*</span>必须填写</div>
		<div class="category desc">
			<label>已选分类</label>
			<ul>
				<?php foreach($this->category as $cat):?>
                <li>
                  <?php 
                    $tmp = array();
                    foreach($cat->getParentTree() as $p) {
                        $tmp[] = $p->name;
                    }
                    echo implode(' &gt; ', $tmp);
                  ?>
                </li>
              	<?php endforeach;?>
			</ul>
		</div>
		<input type="hidden" name="adid" id="adid" value="<?php echo $this->adid?>">
        <?php foreach($this->category as $cat):?>
            <input type="hidden" name="category[]" value="<?php echo $cat->_id?>">
        <?php endforeach;?>
		<div class="title text">
          	<label><span class="required">*</span>招聘职位</label>
          	<?php echo $this->form->tl_en ?> 
          	<span class="remark counter_title">剩余<em>100</em>字</span>
          	<?php if (!empty($_POST['tl_en'])): ?>
              	<?php if (preg_match("#.[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}.#", $_POST['tl_en'])): ?>
                  	<ul class="errors"><li><?php echo $this->t('请勿输入邮箱地址')?></li></ul>
              	<?php endif;?>
          	<?php endif; ?>
          	<?php if(!empty($errors['tl_en'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->tl_en->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
        </div>
		<div class="text company">
			<label><span class="required">*</span>公司名称</label>
			<?php echo $this->form->cn_en ?>
			<span class="remark counter_company">剩余<em>100</em>字</span> 
			<?php if(!empty($errors['cn_en'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->cn_en->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
		</div>
		
		<div class="nature radio">
			<span><span class="required">*</span>工作性质</span>
			<?php echo $this->form->employmenttype ?>
			<?php if(!empty($errors['employmenttype'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->employmenttype->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?>
		</div>
		
		<div class="salary_section section">
			<div class="desc">
				<h4><span class="required">*</span>月薪或时薪</h4>
				<p>请至少填写一项薪水标准</p>
			</div>
			<div class="salary month select col6">
				<label>月薪</label>
				<?php echo $this->form->salary ?>
				<?php if(isset($_POST['salary'])):?>
				<?php if(empty($_POST['salary']) && empty($_POST['salary_hour'])):?>
          		<ul class="errors">
				  	<li>请在下拉菜单选择一个选项，不能为空</li>
				</ul>
          		<?php endif;?>
          		<?php endif;?>
				<?php if(!empty($errors['salary'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->salary->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
			</div>
			<div class="price rent select col6">
				<label>时薪</label>
				<?php echo $this->form->salary_hour ?>
				<?php if(isset($_POST['salary'])):?>
				<?php if(empty($_POST['salary']) && empty($_POST['salary_hour'])):?>
          		<ul class="errors">
				  	<li>请在下拉菜单选择一个选项，不能为空</li>
				</ul>
          		<?php endif;?>
          		<?php endif;?>
				<?php if(!empty($errors['salary_hour'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->salary_hour->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
			</div>
		</div>
		<div class="exp select col6">
			<label><span class="required">*</span>工作经验要求</label>
			<?php echo $this->form->yearexperience ?>
			<?php if(!empty($errors['yearexperience'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->yearexperience->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
		</div>
		<div class="edu select col6">
			<label><span class="required">*</span>学历要求</label>
			<?php echo $this->form->educationlevel ?>
			<?php if(!empty($errors['educationlevel'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->educationlevel->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
		</div>  
		
		
		<div class="textarea description">
            <label><span class="required">*</span>职位描述</label>
            <?php echo $this->form->cs_en?>
			<?php if (!empty($_POST['cs_en'])) { ?>
            <?php if (preg_match("#.[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}.#", $_POST['cs_en'])) { ?>
            	<ul class="errors"><li><?php echo $this->t('请勿输入邮箱地址')?></li></ul>
            <?php } } ?>
            <span class="remark counter_description">还可以输入<em>3000</em>字；为避免收到垃圾邮件，请勿输入邮箱地址</span> 
            <?php if(!empty($errors['cs_en'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->cs_en->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
		</div>
		<div class="radio price">
			<span>发布地区</span>
			<?php foreach ($this->form->loc_flag->options as $k => $opt):?>
				<label>	
					<input type="radio" name="loc_flag" id="price-<?php echo $k?>" value="<?php echo $k?>" <?php echo $this->form->loc_flag->getValue() == $k ? 'checked' : ''?>>
					<?php echo $opt?>
				</label>
			<?php endforeach;?>
		</div>
		<div class="select text address">
            <label><span class="required">*</span>工作地点</label>
            
            <?php echo $this->form->area_l1 ?>
			<?php echo $this->form->area_l2 ?>
			<span class="remark">请在下拉菜单选择一个选项，不能为空</span> 
			<?php if(!empty($errors['area_l1'])):?>
          		<ul class="errors">
          			<?php foreach($this->form->area_l1->getMessages() as $errmsg):?>
				  	<li><?php echo $errmsg?></li>
				  	<?php endforeach;?>
				</ul>
          	<?php endif;?> 
          	<?php if(isset($_POST['area_l1']) && !empty($_POST['area_l1'])):?>
			<?php if(empty($_POST['area_l2']) && $_POST['area_l1']!=ENTIRE_CITY):?>
          		<ul class="errors">
				  	<li>请在下拉菜单选择一个选项，不能为空</li>
				</ul>
          	<?php endif;?> 
          	<?php endif;?> 
		</div>

        <div class="tag text">
			<label>关键字</label>
			<?php echo $this->form->tag ?>
			<span class="remark">输入关键字有助于你的宝贝更容易被发现，各关键词请以逗号(，)分隔<br>
			(如：苹果，Apple，Iphone，32G)</span> 
		</div>
		<div class="remark text">
			<label>一句话描述</label>
			<?php echo $this->form->remark ?>
			<span class="remark">此描述会放在搜索结果及在本信息置顶，帮助买家更了解你的宝贝</span> 
		</div>
		<div class="contact_section section">
			<div class="desc">
				<h4>联络人资料</h4>
				<p>对你宝贝感兴趣的人应该联络谁</p>
			</div>
			<div class="contact_name text">
				<label>联系人</label>
				<?php echo $this->form->c_name ?>
			</div>          
			<div class="tel text col6">
				<label>电话号码</label>
				<?php echo $this->form->c_tel ?>
			</div>
			<div class="msn_qq text col6">
				<label>MSN / QQ</label>
				<?php echo $this->form->c_msn ?>
			</div>
		</div>
	</fieldset>
	<fieldset class="photo">
        <legend>图片</legend>
        <?php echo $this->Partial('/index/photo-uploader.phtml', 'listing', array('listing' => $this->listing));?>
		<div class="action">

          	<div class="button back">
            	<a href="<?php echo $this->geturl('post-an-ad', 'listing', null, null, array('category' => $_GET['category'], 'change' => 1))?>">返回上一步</a>
            	<!--button type="submit">返回上一步</button-->
          	</div>
          	<div class="button em submit">
            	<button type="submit" name="postyourad">下一步</button>
          	</div>
          	<!--div class="button em">
	          <button type="submit" name="postyourad"><?php echo $this->t('Post Your Ad')?></button>
	        </div>
	        <div class="preview button">
	           <button id="review-your-ad" type="submit" name="review"><?php echo $this->t('Edit Translation')?></button>
	        </div-->
        </div>
	</fieldset>
</form>
